<?php
namespace wlcat\http\MiddleWare;
use wlcat\src\Request;

class InitGlobalFrameMiddleWare implements MiddleFrameWareInterface{
    public function handle(Request $request, \Closure $next)
    {
        if (ini_get('register_globals')) {
            $array = array('_SESSION', '_POST', '_GET', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES');
            foreach ($array as $value) {
                foreach ($GLOBALS[$value] as $key => $var) {
                    if ($var === $GLOBALS[$key]) {
                        unset($GLOBALS[$key]);
                    }
                }
            }
        }

        return $next($request);
    }
}